/*
 * ============================================================================
 * = COPYRIGHT
 *          PAX Computer Technology(Shenzhen) Co., Ltd. PROPRIETARY INFORMATION
 *   This software is supplied under the terms of a license agreement or nondisclosure
 *   agreement with PAX Computer Technology(Shenzhen) Co., Ltd. and may not be copied or
 *   disclosed except in accordance with the terms in that agreement.
 *     Copyright (C) 2021 PAX Computer Technology(Shenzhen) Co., Ltd. All rights reserved.
 * ============================================================================
 */

import 'package:pigeon/pigeon.dart';


@ConfigurePigeon(PigeonOptions(
    dartOut: 'lib/auto_pigeon/poslink_sdk_ped.dart',
    javaOptions: JavaOptions(
      className: 'POSLinkPed',
      package: 'com.example.pos_link.pigeon',
    ),
    objcOptions: ObjcOptions(prefix: ''),
    javaOut: './android/src/main/java/com/example/pos_link/pigeon/POSLinkPed.java',
  ),
)
class PedMacCalculationRequest {
  String? inputData;
  String? encryptionBitmap;
  String? macKeySlot;
  PedMacWorkMode? macWorkMode;
  String? encryptionKeySlot;
  String? paddingChar;
  PedMacKeyType? macKeyType;
  PedKsnFlag? ksnFlag;
}

class PedSessionKeyInjectionRequest {
  String? sourceKeyType;
  String? sourceKeyIndex;
  PedDestinationKeyType? destinationKeyType;
  String? destinationKeyIndex;
  String? destinationKeyValue;
  PedCheckMode? checkMode;
  String? checkBuffer;
}

class PedIncreaseKsnRequest {
  PedKeyType? keyType;
  String? keySlot;
}

class PedGetPedInformationRequest {
  PedKeyType? keyType;
  String? keySlot;
}

class PedMasterSessionKeyInformation {
  String? keySlot;
  String? kcv;
}

class PedDukptKeyInformation {
  String? keySlot;
  String? ksn;
  String? kcv;
}

class PedGetPedInformationResponse {
  String? responseCode;
  String? responseMessage;
  String? masterAvailableKeySlotCount;
  String? sessionAvailableKeySlotCount;
  String? dukptAvailableKeySlotCount;
  String? aesDukptAvailableKeySlotCount;
  List<PedMasterSessionKeyInformation?>? tmk;
  List<PedMasterSessionKeyInformation?>? tpk;
  List<PedMasterSessionKeyInformation?>? tak;
  List<PedMasterSessionKeyInformation?>? tdk;
  List<PedDukptKeyInformation?>? dukptKey;
  List<PedDukptKeyInformation?>? aesDukptKey;
}

class PedMacCalculationResponse {
  String? responseCode;
  String? responseMessage;
  String? resultData;
  String? ksn;
}

class PedSessionKeyInjectionResponse {
  String? responseCode;
  String? responseMessage;
}

class PedIncreaseKsnResponse {
  String? responseCode;
  String? responseMessage;
  String? ksn;
}

enum PedKeyType {
  NotSet,
  MasterKey,
  SessionKey,
  DesDukptKey,
  AesDukptKey,
}

enum PedDestinationKeyType {
  NotSet,
  Tpk,
  Tak,
  Tdk,
}

enum PedCheckMode {
  NotSet,
  NoKcvCheck,
  DesOrTdesEncryptionAndCheckKcv,
}

enum PedMacWorkMode {
  NotSet,
  AnsiX99,
  HypercomFastMode,
  AnsiX919,
  Sha1,
  Sha256,
}

enum PedMacKeyType {
  NotSet,
  Tak,
  DesDukptKey,
  AesDukptKey,
  Hmac,
}

enum PedKsnFlag {
  NotSet,
  NotIncrease,
  Increase,
}

@HostApi()
abstract class POSLinkPedApi {
   @async
   PedGetPedInformationResponse getPedInformation(PedGetPedInformationRequest req);
   @async
   PedIncreaseKsnResponse increaseKsn(PedIncreaseKsnRequest req);
   @async
   PedSessionKeyInjectionResponse sessionKeyInjection(PedSessionKeyInjectionRequest req);
   @async
   PedMacCalculationResponse macCalculation(PedMacCalculationRequest req);
}
